package com.itheima.reggie.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Mybatis相关配置。eg：分页插件
 *
 * @Author Vsunks.v
 * @Date 2023/2/5 9:06
 * @Blog blog.sunxiaowei.net/996.mba
 * @Description: Mybatis相关配置。eg：分页插件
 */
@Configuration
@MapperScan("com.itheima.reggie.mapper")  // 扫描指定包下所有mapper，一劳永逸
public class MybatisConfig {

    /**
     * 定义一个方法，装配Mybatis分页插件
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {

        MybatisPlusInterceptor mpi = new MybatisPlusInterceptor();
        PaginationInnerInterceptor pii = new PaginationInnerInterceptor();

        // 分页插件可以设置参数
        pii.setOverflow(true);
        mpi.addInnerInterceptor(pii);

        return mpi;
    }


}
